<template>
	<view>
		<view class="uni-list" style="margin-bottom: 32upx;">
			<block v-for="(item, index) in data" :key="index">
		        <list-good-swiper :data="item" :index="index" @click="_clickListGood" @change="_changeListGood">
                    <view style="color: #007AFF;font-size: 20upx;">
                    	其他内容({{data.size}})
                    </view>
                    <template slot="numbox">
                    	{{data.size==-1?'到货提醒':data.size==-2?'停止销售':''}}
                    </template>
		        </list-good-swiper>
		    </block>
		</view>
	</view>
</template>

<script>
    import uniIcon from '@/components/uni-icon/uni-icon.vue';
    import listGoodSwiper from '@/components/wlp-list-good-swiper/wlp-list-good-swiper.vue';
    
	export default {
        components:{
            uniIcon,
            listGoodSwiper
        },
		data() {
			return {
				data: [
				    {
				        title: '香水菠萝vvv香水菠萝香水菠萝香水菠萝s',
				        imgUrl: '/static/temp/good.jpg',
				        label: '特惠',
				        sku: [{name:'300/g 每盒'},{name:'300/g 每盒'}],
				        price: '9.9',
				        originalPrice: '45',
				        size: 3,
                        checked: true
				    },
				    {
				        title: '香水菠萝vvv香水菠萝香水菠萝香水菠萝s',
				        imgUrl: '/static/temp/good.jpg',
				        label: '特惠',
				        sku: [{name:'300/g 每盒'}],
				        price: '9.9',
				        originalPrice: '45',
				        size: 1,
                        checked: false
				    },
				    {
				        title: '香水菠萝vvv香水菠萝香水菠萝香水菠萝s',
				        imgUrl: '/static/temp/good.jpg',
				        sku: [{name:'300/g 每盒'}],
				        price: '9.9',
				        size: -1,
                        checked: false
				    },
				    {
				        title: '香水菠萝vvv香水菠萝香水菠萝香水菠萝s',
				        imgUrl: '/static/temp/good.jpg',
				        price: '9.9',
				        size: -2,
                        checked: false
				    }
				]
			};
		},
        methods: {
            _clickListGood(index, type){
                if(type == 'checked'){
                    this.data[index].checked = !this.data[index].checked;
                    return;
                }
                if(type == 'del'){
                    let _this = this;
                    uni.showModal({
                        title: '删除',
                        content: '确定要删除宝贝吗！',
                        confirmText: '删除',
                        confirmColor: '#dd524d',
                        success: function (res) {
                            if (res.confirm) {
                                _this.data.splice(index, 1);
                            } else if (res.cancel) {
                                console.log('用户点击取消');
                            }
                        }
                    });
                    return;
                }
                console.log(index+":"+type)
            },
            _changeListGood(value, index){
                this.data[index].size = value;
            }
        }
	}
</script>

<style lang="scss">

</style>
